import {request} from '@/base/Request';
import {RoleRelationship} from '@/base/model/RoleRelationship';
import qs from 'qs'

export function getRoleRelationshipList(params: {
    pageIndex: number,
    pageSize: number,
    masterId: number,
    agentName?: string
  }) {
    return request.getPage(RoleRelationship, `/api/role-relationship/fetch?pageIndex=${params.pageIndex}&pageSize=${params.pageSize}&masterId=${params.masterId}&agentName=${params.agentName}`)
  }

export function getRoleRelationship() {
    return request.get(RoleRelationship, '/api/role-relationship');
}

export function getRoleRelationshipById(id: number) {
    return request.get(RoleRelationship, `/api/role-relationship/${id}`);
}

export function getRoleRelationshipByMasterId(id: number) {
    return request.get(RoleRelationship, `/api/role-relationship/findByMasterId/${id}`);
}

export function postRoleRelationship(params: {
    id: number,
    masterId: number,
    salveId: number,
    created: string,
    updated: string
  }) {
    return request.post(RoleRelationship, '/api/role-relationship/findByMasterId',qs.stringify(params));
}

export function batchSaveRoleRelationship(params: {
  masterId: number,
  ids: string
}) {
  return request.post(RoleRelationship, `/api/role-relationship/batchSave?masterId=${params.masterId}&ids=${params.ids}`);
}

export function putRoleRelationship(params: {
    id: number,
    masterId: number,
    salveId: number,
    created: string,
    updated: string
  }) {
    return request.put(RoleRelationship, '/api/role-relationship/findByMasterId',qs.stringify(params));
}


export function deleteRoleRelationship(id: number){
  return request.delete(`/api/role-relationship/${id}`);
}
